function pages(page: string) {
  return () => import(`@pages/${page}.vue`);
}

function views(page: string) {
  return () => import(`@views/${page}.vue`);
}

function comps(name: string) {
  return () => import(`@components/${name}.vue`);
}

export const routes = [
  {
    path: "/login",
    name: "login",
    component: pages("Login"),
    meta: { title: "登录" }
  },
  {
    path: "/",
    name: "main",
    redirect: "/index", //重定向到子页面
    component: pages("Main"),
    meta: { title: "首页" },
    children: [
      {
        path: "/index",
        name: "index",
        component: pages("Index"),
        meta: { title: "首页", aliveFlag: false }
      },
      {
        path: "/form",
        name: "form",
        component: pages("base/BaseForm"),
        meta: { title: "表单与上传图片" }
      },
      {
        path: "/knowledge",
        name: "knowledge",
        component: pages("base/BaseKnowledge"),
        meta: { title: "基础知识" }
      },
      {
        path: "/basedom",
        name: "basedom",
        component: pages("base/BaseDom"),
        meta: { title: "vue操作Dom" }
      },
      {
        path: "/virtualtree",
        name: "virtualtree",
        component: pages("base/VirtualTree"),
        meta: { title: "性能渲染大数据Tree" }
      },
      {
        path: "/renderBtns",
        name: "renderBtns",
        component: pages("jsx/JsxFunction"),
        meta: { title: "渲染btns不同状态" }
      },
      {
        path: "/customComponents",
        name: "customComponents",
        component: pages("base/CustomComponents"),
        meta: { title: "自定义组件" }
      },
      {
        path: "/baseslot",
        name: "baseslot",
        component: pages("base/BaseSlot"),
        meta: { title: "插槽" }
      },
      {
        path: "/basevpay",
        name: "basevpay",
        component: pages("base/BaseVpay"),
        meta: { title: "支付组件" }
      },
      {
        path: "/headerswiper",
        name: "headerswiper",
        component: pages("swiper/HeaderSwiper"),
        meta: { title: "轮播" }
      },
      {
        path: "/calendar",
        name: "calendar",
        component: pages("calendar/DataCalendar"),
        meta: { title: "校历" }
      },
      {
        path: "/detail",
        name: "detail",
        component: pages("calendar/DetailCalendar"),
        meta: { title: "校历详情" }
      },
      {
        path: "/datacenter",
        name: "datacenter",
        component: pages("datacenter/DataCenter"),
        meta: { title: "设置数据" }
      },
      {
        path: "/staffphoto",
        name: "staffphoto",
        component: pages("datacenter/StaffPhoto"),
        meta: { title: "证件照" }
      },
      {
        path: "/apppush",
        name: "apppush",
        component: pages("datacenter/AppPush"),
        meta: { title: "公有云应用" }
      },
      {
        path: "/throttlefunc",
        name: "throttlefunc",
        component: pages("ThrottleFunc"),
        meta: { title: "防抖与节流" }
      },
      {
        path: "/renderfunc",
        name: "renderfunc",
        component: pages("RenderFunc"),
        meta: { title: "JSX函数式组件" }
      },
      {
        path: "/cssfunc",
        name: "cssfunc",
        component: pages("css/CssFunc"),
        meta: { title: "事件冒泡" }
      },
      {
        path: "/maskcss",
        name: "maskcss",
        component: pages("css/MaskCss"),
        meta: { title: "滑动穿透" }
      },
      {
        path: "/basecss",
        name: "basecss",
        component: pages("css/BaseCss"),
        meta: { title: "Css基础" }
      },
      {
        path: "/gridCss",
        name: "gridCss",
        component: pages("css/GridCss"),
        meta: { title: "grid网格布局" }
      }
    ]
  },
  // 错误页
  {
    path: "/401", //全不匹配的情况下，返回401，路由按顺序从上到下，依次匹配。最后一个*能匹配全部，
    name: "401",
    meta: {
      title: "无权限"
    },
    component: comps("iv-error/Error401")
  },
  {
    path: "*", //全不匹配的情况下，返回401，路由按顺序从上到下，依次匹配。最后一个*能匹配全部，
    name: "404",
    meta: {
      title: "未找到页面"
    },
    component: comps("iv-error/Error404")
  }
];
